package com.mark.utils;

import java.util.Random;

public class StudentUtil {


    public static String getRandomPass() {
        Random random = new Random();
        StringBuilder password = new StringBuilder();
        for (int i = 0; i < 8; i++) {
            // 1、2随机生成整数  如果 1就生成字符 2则生成数字
            String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
            //生成字符
            if (charOrNum.equals("char")) {
                // 判断是生成大写还是小写
                int choice = random.nextInt(2) == 0 ? 65 : 97;
                password.append((char) (choice + random.nextInt(26)));
            } else { //生成数字
                password.append(random.nextInt(10));
            }
        }
        return String.valueOf(password);
    }

}
